package com.example.filetest;

/*
 * exception异常处理
 * */

import com.example.domain.AgeOutOfBoundsException;
import com.example.domain.GirlFriend;
import com.example.domain.NameFormatException;

import java.util.Scanner;


public class Test08 {
    public static void main(String[] args) {

        GirlFriend girlFriend = new GirlFriend();

        while (true) {
            try {
                Scanner scanner = new Scanner(System.in);
                System.out.println("请输入名字: ");
                girlFriend.setName(scanner.nextLine());
                System.out.println("请输入年龄: ");
                girlFriend.setAge(scanner.nextInt());
                System.out.println(girlFriend);
                break;
            } catch (NameFormatException e) {
                e.printStackTrace();
            } catch (AgeOutOfBoundsException e) {
                e.printStackTrace();
            }
        }

    }
}
